import Vue from 'vue'
import VueRouter from 'vue-router'
import About from '@/pages/About.vue'
import Home from '@/pages/Home.vue'
import News from '@/pages/News.vue'
import Message from '@/pages/Message.vue'
import Detail from '@/pages/Detail.vue'

Vue.use(VueRouter)

//创建一个router，用于控制整个应用的路由规则
const router = new VueRouter({
	mode:'history',
	routes:[
		{
			name:'guanyu',
			path:'/about',
			component:About
		},
		{
			name:'zhuye',
			path:'/home',
			component:Home,
			children:[
				{
					name:'xinxi',
					path:'message',
					component:Message,
					children:[
						{
							name:'xiangqing',
							path:'detail',
							component:Detail,
							//props配置的第一种写法 —— 对象写法
							// props:{a:100,b:200,c:300}

							//props配置的第二种写法 —— 布尔值写法
							// props:true

							//props配置的第三种写法 —— 函数式写法
							props(currentRoute){
								// console.log('*****',currentRoute)
								return currentRoute.query
							}
						}
					]
				},
				{
					name:'xinwen',
					path:'news',
					component:News
				}
			]
		}
	]
})

export default router